// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include "runtime_types.h"
#include "interface.h"
#include "mem_alloc.h"

void *__go_new (uintptr size);
void *__go_new_nopointers (uintptr size);

// We should be OK if we don't split the stack here, since we are just
// calling memmove which shouldn't need much stack.  If we don't do
// this we will always split the stack, because of memmove.
void __go_copy (void *, void *, uintptr) __attribute__((no_split_stack));

// The generic go new() function.

void *
__go_new (uintptr size)
{
	return runtime_mallocgc (size, 0, 1, 1);
}

void *
__go_new_nopointers (uintptr size)
{
	return runtime_mallocgc (size, FlagNoPointers, 1, 1);
}

void
__go_copy (void *a, void *b, uintptr len)
{
	__builtin_memmove (a, b, len);
}
